/*
 * @lastUpdateBy : 唐贵香
 * @description: 标注管理相关接口
 */

var axios = agcim.net.http;
export default {
	get(url, params) {
		return new Promise((resolve, reject) => {
			axios.get(url, { params: params?params:{} }).then(
				(response) => {
					if (response.success) {
						resolve(response);
					} else {
						reject(response);
					}
				},
				(error) => {
					reject(error);
				}
			);
		})
	},
	post(url, params) {
		return new Promise((resolve, reject) => {
			axios({
				url: url,
				method: 'post',
				data: {
					...params
				},
				headers: {
					// 'Content-Type': 'multipart/form-data'//含有附件的表单提交的Content-Type
					'Content-Type': 'application/x-www-form-urlencoded',//普通表单提交的Content-Type,
					'Authorization': 'bearer ' + localStorage.getItem("access_token")
				},
				transformRequest: [data => {
					let formData = new FormData()
					for (let key in params) {
						formData.append(key, params[key])
					}
					return formData
				}],
			}).then(res => {
				if (res.success) {
					resolve(res);
				} else {
					reject(res);
				}
			}).catch(err => { reject(err) })
		})
	},
	//获取标注列表
	getMarkers(url) {
		return new Promise((resolve, reject) => {
			axios.get(url).then(
				(response) => {
					if (response.success) {
						resolve(response);
					} else {
						reject(response);
					}
				},
				(error) => {
					reject(error);
				}
			);
		})
	},



};
